#include "ui/mainwindow.h"

#include <QApplication>
#include <QTranslator>
#include <QLocale>
#include <QTextCodec>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    
    // 设置默认编码为 UTF-8
    #if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
        QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
        QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    #endif
    
    // 设置应用程序信息
    QApplication::setApplicationName("ExtractCore");
    QApplication::setApplicationVersion("1.0.0");
    QApplication::setOrganizationName("ExtractCore");
    
    // 加载翻译文件
    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "ExtractCore_" + QLocale(locale).name();
        if (translator.load(":/translations/" + baseName)) {
            QApplication::installTranslator(&translator);
            break;
        }
    }
    
    MainWindow w;
    w.show();
    return a.exec();
} 